<?php include("config.php"); ?>

<html>
<head>
<title><?php echo($name); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>
<body>
<h1><?php echo($name); ?></h1>

<div style="background-color: blue; color: white;"><h3>Redirektor</h3></div>
<!--Contenu de la page ici-->

<?php
if(!isset($_POST['user'])) {
//Formulaire
?>
<form action="register.php" method="post">
<p>Nom d'utilisateur: <input type="text" name="user" /></p>
<p>Mot de passe: <input type="password" name="pass" /></p>
<p>Confirmer: <input type="password" name="pass2" /></p>
<p>E-mail: <input type="text" name="mail" /></p>
<p><input type="submit" value="Inscription" />
</form>
<?php
}
else {
extract($_POST);
if(($pass != $pass2)) {
?>
<h1>Erreur</h1>
<p>Les mots de passe ne concordent pas</p>
<?php
}
elseif((isset($pass)) AND (strlen($pass)<6)) {
?>
<h1>Erreur</h1>
<p>Le mot de passe n'est pas sûr</p>
<?php
}
else {
dbconnect();
$req = mysql_query("SELECT * FROM ".$prefix."user WHERE `login` = '".$user."' LIMIT 1");
echo(mysql_error());
$data = mysql_fetch_assoc($req);
if($user == $data['login']) {
echo("<h3>Pseudo déjà pris</h3>");

}
else {
//Inscription
mysql_query("INSERT INTO `".$prefix."user` (`id`, `login`, `pass`, `status`, `mail`) VALUES (NULL, '".$user."', '".md5($pass)."', 'user', '".$mail."');");
echo(mysql_error());
echo("OK");
}
}
}
?>

</body>
</html>

